package com.fwtai.controller.web;

import com.fwtai.service.web.ProxyService;
import com.fwtai.service.web.SpecialAreaService;
import com.fwtai.tool.ToolClient;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;

/**
 * 特殊区域代理
 * @作者 田应平
 * @版本 v1.0
 * @QQ号码 444141300
 * @Email service@fwtai.com
 * @创建日期 2023-08-29 11:28:52
 * @官网 <url>http://www.fwtai.com</url>
*/
@RestController
@RequestMapping("/specialArea")
public class SpecialAreaController{

  private final SpecialAreaService specialAreaService;

  private final ProxyService proxyService;

  public SpecialAreaController(final SpecialAreaService specialAreaService,final ProxyService proxyService){
    this.specialAreaService = specialAreaService;
    this.proxyService = proxyService;
  }

  //查询特殊区域代理列表
  @PreAuthorize("hasAuthority('special_area_btn_proxy')")
  @GetMapping("/listAreaProxy")
  public void listAreaProxy(final HttpServletResponse response){
    ToolClient.responseJson(specialAreaService.listAreaProxy(),response);
  }

  //获取区域下的门店列表
  @PreAuthorize("hasAuthority('special_area_btn_shop')")
  @GetMapping("/listAreaShop")
  public void listAreaShop(final String userId,final HttpServletResponse response){
    ToolClient.responseJson(specialAreaService.listAreaShop(userId),response);
  }

  /**修改密码重置密码*/
  @PreAuthorize("hasAuthority('special_area_row_edit')")
  @PostMapping("/editUser")
  public void editUser(final Long userId,final String user_password,final String verify_password,final HttpServletResponse response){
    ToolClient.responseJson(proxyService.editUser(userId,user_password,verify_password),response);
  }
}